package com.example.qqlaobing.Umoney.adapter;

import android.os.Debug;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.qqlaobing.Umoney.R;
import com.example.qqlaobing.Umoney.view.fragment.bean.MyLoanBean;
import com.example.qqlaobing.Umoney.view.fragment.home.act.bean.LoanRecognitionBean;
import com.google.gson.Gson;

import java.util.List;

public class LoanAdapter1 extends BaseQuickAdapter<MyLoanBean.DataBean.LoanListBean, BaseViewHolder> {
    public LoanAdapter1(@Nullable List<MyLoanBean.DataBean.LoanListBean> data) {
        super(R.layout.item_loan, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MyLoanBean.DataBean.LoanListBean item) {
        helper.setText(R.id.overduefee, "￥" + item.getNeed_pay())
                .setText(R.id.qs, item.getQs() + "期")
                .setText(R.id.damount, "￥" + item.getDamount() + "")
                .setText(R.id.tv_time, item.getAddtime());
        if (item.getPay_url() != null && !item.getPay_url().equals("")) {
            helper.setText(R.id.tv_type, "立即还款");
            helper.addOnClickListener(R.id.tv_type);
            helper.getView(R.id.myImage).setVisibility(View.VISIBLE);
            Glide.with(mContext).load(R.mipmap.repayment_pic_among_repayments).into((ImageView) helper.getView(R.id.myImage));
        } else {
            helper.setText(R.id.overduefee, "￥0.00" );
            helper.getView(R.id.myImage).setVisibility(View.GONE);
            helper.setText(R.id.tv_type, "已还款");
        }
        if (item.getOverdue_days() > 0) {
            helper.getView(R.id.myImage).setVisibility(View.VISIBLE);
            Glide.with(mContext).load(R.mipmap.repayment_pic_be_overdue).into((ImageView) helper.getView(R.id.myImage));
            helper.setText(R.id.yuqitianshu, "逾期天数：" + item.getOverdue_days() + "天");
            helper.setText(R.id.tv_type, "立即还款");
            helper.addOnClickListener(R.id.tv_type);
        }
    }
}